import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(title: const Text("你好Flutter")),
      body: Column(
        children: [
          MyApp(),
          MyButton(),
          MyText()
        ],
      ),
    ),
  ));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
      child: Container(
          margin: const EdgeInsets.fromLTRB(0, 40, 0, 0),
          alignment: Alignment.center,
          width: 400,
          height: 400,
          // transform: Matrix4.translationValues(30, 0, 0),//设置位移分别是xy和未知
          decoration: BoxDecoration(
              color: Colors.cyan, //背景颜色
              border: Border.all(color: Colors.amber, width: 1),//配置边框
              borderRadius: BorderRadius.circular(200),//配置圆角边框
              boxShadow: const[BoxShadow(color: Colors.red,blurRadius: 20.0)],//设置阴影
              gradient: const LinearGradient(colors:[Colors.yellow,Colors.blue]),//设置渐变色，LinearGradient背景线性渐变
              // gradient: const RadialGradient(colors: [Colors.green,Colors.yellow]),//RadialGradient背景径向渐变
          ),
          child: const Text(
            "你好!flutter,我是一个自定义组件",
            textDirection: TextDirection.ltr,
            style: TextStyle(
                color: Colors.cyanAccent,
                //   color: Color.fromRGBO(244, 244, 1, 1),
                fontSize: 30),
          )),
    );
  }
}

class MyButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      alignment: Alignment.center,
      transform: Matrix4.rotationZ(0.2),
      width: 200,
      height: 50,
      margin: const EdgeInsets.fromLTRB(0, 30, 0, 0),
      decoration:  BoxDecoration(
        color: Colors.amberAccent,
        borderRadius: BorderRadius.circular(10)//设置圆角边框
      ),
      child: const Text("按钮1",style: TextStyle(
        color: Colors.green,
        fontSize: 20
      ),),
    );
  }
}

class MyText extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      width: 300,
      height: 300,
      margin: const EdgeInsets.fromLTRB(0, 40, 0, 0),
      decoration: const BoxDecoration(color: Colors.blue),
        child: const Text("幸好我是flutter幸好我是flutter幸好我是flutter幸好我是flutter幸好我是flutter幸好我是flutter幸好我是flutter",
          textAlign: TextAlign.center,
          overflow: TextOverflow.ellipsis,//溢出显示几个点
          maxLines: 2,
          style: TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.w600,
            color: Colors.cyan,
            fontStyle: FontStyle.italic,
            letterSpacing: 4,
            decoration: TextDecoration.underline,
            decorationColor: Colors.yellow,
            decorationStyle: TextDecorationStyle.dashed
          ),
        ),
    );
  }

}